
using System;
using System.Collections;
using System.Collections.Generic;



namespace raycsharp
{


	public class Scene
	{
		public List<SceneObject> objects;
		public List<Light> lights;
		public Scene() {
			objects = new List<SceneObject>();
			lights = new List<Light>();
		}
		
		public IntersectionResult nearest_object(Ray ray) {
			IntersectionResult min_ir = new IntersectionResult();
			double min_distance = double.PositiveInfinity;
			foreach(SceneObject obj in objects) {
				IntersectionResult ir = obj.intersection(ray);
				double test_distance = ir.distance;
				if(!ir.status)
					continue;
				if(test_distance < min_distance) {
					min_ir = ir;	
					min_distance = test_distance;
				}
			}
			return min_ir;
		}
	}
}
